<!-- 数据统计模块 -->
<template>
	<view
		class="block-statistics"
		:style="'order:'+Item.order+';'+Item.boxCss">
		<view class="for" v-if="Item.postDigit.switch">
			<view :style="Item.postDigit.digitCss">{{postDigit}}</view>
			<view :style="Item.postDigit.textCss">{{Item.postDigit.text}}</view>
		</view>
		<view class="for" v-if="Item.commentDigit.switch">
			<view :style="Item.commentDigit.digitCss">{{commentDigit}}</view>
			<view :style="Item.commentDigit.textCss">{{Item.commentDigit.text}}</view>
		</view>
		<template v-if="$_loginOrNot()">
			<view class="for" v-if="Item.myPostDigit.switch">
				<view :style="Item.myPostDigit.digitCss">{{myPostDigit}}</view>
				<view :style="Item.myPostDigit.textCss">{{Item.myPostDigit.text}}</view>
			</view>
			<view class="for" v-if="Item.myCommentDigit.switch">
				<view :style="Item.myCommentDigit.digitCss">{{myCommentDigit}}</view>
				<view :style="Item.myCommentDigit.textCss">{{Item.myCommentDigit.text}}</view>
			</view>
		</template>
	</view>
</template>

<script>
	export default {
		name:"block-statistics",
		props:{
			Item:{
				type:Object,
				default:null
			}
		},
		data() {
			return {
				postDigit:0,
				commentDigit:0,
				myPostDigit:0,
				myCommentDigit:0,
			};
		},
		mounted(){
			this.getPostList();
		},
		methods:{
			// 总发帖数
			getPostList(){
				this.$_Request(
					"GET","/api/v2/post/list",
					{
						"createdDays":this.Item.postDigit.days,
						"pageSize":1,
						"whitelistKeys":"pid"
					},
					(res) => {
						this.postDigit = res.data.data.pagination.total;
						this.getCommentList();
					}
				)
			},
			// 总回复数
			getCommentList(){
				this.$_Request(
					"GET","/api/v2/comment/list",
					{
						"createdDays":this.Item.commentDigit.days,
						"pageSize":1,
						"whitelistKeys":"cid"
					},
					(res) => {
						this.commentDigit = res.data.data.pagination.total;
						this.getMyPostList();
					}
				)
			},
			// 我发帖的
			getMyPostList(){
				this.$_Request(
					"GET","/api/v2/post/list",
					{
						"uidOrUsername":uni.getStorageSync('user').data.detail.uid,
						"createdDays":this.Item.myPostDigit.days,
						"pageSize":1,
						"whitelistKeys":"pid"
					},
					(res) => {
						this.myPostDigit = res.data.data.pagination.total;
						this.getMyCommentList();
					}
				)
			},
			// 我回复的
			getMyCommentList(){
				this.$_Request(
					"GET","/api/v2/comment/list",
					{
						"uidOrUsername":uni.getStorageSync('user').data.detail.uid,
						"createdDays":this.Item.myCommentDigit.days,
						"pageSize":1,
						"whitelistKeys":"cid"
					},
					(res) => {
						this.myCommentDigit = res.data.data.pagination.total;
					}
				)
			}
		}
	}
</script>

<style lang="scss" scoped>
.block-statistics{
	.for{
		display: flex;
		align-items: center;
		justify-content: center;
		flex-flow: column;
		padding: 0 12.5rpx;
	}
	.for:last-child{
		border-right: 0;
	}
}
</style>